package com.fare.taluo.auth.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.auth.domain.repository.UserInfoLogRepositry;

/**
 * 用户登录日志
 * @author 2014-05-21
 */
@Entity
@Table(name="sys_userinfo_log")
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class UserInfoLogEntity extends com.fare.taluo.base.ddd.domain.baseentity.BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Column(name ="create_time")
	private Date createTime;
	
	@Column(name ="username")
	private String userName;
	
	@Column(name ="login_time")
	private Date loginTime;
	
	@Column(name ="logout_time")
	private Date logoutTime;
	
	@Column(name ="online_time")
	private String onlineTime;
	
	@Column(name ="login_ip")
	private String IP;

	
	private static UserInfoLogRepositry getRepository(){
		return InstanceFactory.getInstance(UserInfoLogRepositry.class);
	}
	
	public UserInfoLogEntity checkUserNmaeLogin(String userName){
		return getRepository().checkUserNmaeLogin(userName);
	}
	
	public void saveOrUpdate(UserInfoLogEntity entity){
		getRepository().saveOrUpdate(entity);
	}
	public void systemUpdate(){
		getRepository().systemUpdate();
	}
	
	public int countUserOnline() {
		return getRepository().countUserOnline();
	}
	
	public List<UserInfoLogEntity> findAll(Date loginTime, Date logoutTime) {
		return getRepository().findAll(loginTime,logoutTime);
	}
	
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public String getOnlineTime() {
		return onlineTime;
	}

	public void setOnlineTime(String onlineTime) {
		this.onlineTime = onlineTime;
	}

	public String getIP() {
		return IP;
	}

	public void setIP(String iP) {
		IP = iP;
	}

	public Date getLogoutTime() {
		return logoutTime;
	}

	public void setLogoutTime(Date logoutTime) {
		this.logoutTime = logoutTime;
	}

	

	
}
